package com.chatbi.service;

import com.chatbi.service.vectorstore.VectorStore;
import com.chatbi.service.vectorstore.VectorStoreFactory;
import org.springframework.stereotype.Service;

@Service
public class TrainServiceImpl implements TrainService {
    
    private final VectorStore vectorStore;
    
    public TrainServiceImpl(VectorStoreFactory vectorStoreFactory) {
        this.vectorStore = vectorStoreFactory.createVectorStore();
    }

    @Override
    public void trainDDL(String ddl) {
        vectorStore.store("ddl", ddl);
    }

    @Override
    public void trainDocumentation(String documentation) {
        vectorStore.store("documentation", documentation);
    }

    @Override
    public void trainSQL(String sql) {
        vectorStore.store("sql", sql);
    }

    @Override
    public void trainQuestionSQLPair(String question, String sql) {
        vectorStore.store("qsql_pair", question + "|||" + sql);
    }

    @Override
    public void trainPlan(String plan) {
        vectorStore.store("plan", plan);
    }
}
